//
// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import InspectorWidget = require("./InspectorWidget");
import InspectorUtils = require("./InspectorUtils");

class AssemblyInspector extends InspectorWidget {

    constructor() {

        super();

        this.subscribeToEvent(this, Atomic.UIWidgetEvent((data) => this.handleWidgetEvent(data)));

    }

    handleWidgetEvent(ev: Atomic.UIWidgetEvent):boolean {

      return false;

    }

    inspect(asset: ToolCore.Asset) {

        this.asset = asset;
        this.importer = <ToolCore.NETAssemblyImporter> asset.importer;

        // node attr layout
        var rootLayout = this.rootLayout;

        // Assembly Section
        var assemblyLayout = this.createSection(rootLayout, "NETAssembly", 1);

        var assemblyFile = <AtomicNETScript.CSComponentAssembly> asset.importer.getResource();

        var container = InspectorUtils.createContainer();
        container.gravity = Atomic.UI_GRAVITY.UI_GRAVITY_ALL;
        assemblyLayout.addChild(container);

        var panel = new Atomic.UILayout();
        panel.axis = Atomic.UI_AXIS.UI_AXIS_Y;
        panel.layoutSize = Atomic.UI_LAYOUT_SIZE.UI_LAYOUT_SIZE_PREFERRED;
        panel.layoutPosition = Atomic.UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_LEFT_TOP;
        container.addChild(panel);

        var label = InspectorUtils.createAttrName("CSComponents:");
        panel.addChild(label);

        for (var index in assemblyFile.classNames) {
            var classname = assemblyFile.classNames[index];

            label = InspectorUtils.createAttrName(classname);
            panel.addChild(label);
        }

    }


    asset: ToolCore.Asset;
    importer:ToolCore.NETAssemblyImporter;

}

export = AssemblyInspector;
